package com.test.ayi.controller;

import com.test.ayi.model.User;
import com.test.ayi.service.UserService;
import com.test.ayi.util.RedisUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * SpEL表达式示例控制器
 * 展示如何使用SpEL访问环境变量和配置属性
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/getByName")
    public User getUserInfo(String name) {
        return userService.getUserByName(name);
    }

    @GetMapping("/saveUser")
    public void getUserInfo(String name, String password) {
        userService.saveUser(User.builder().username(name).password(password).build());
    }

}
